/**
 * @projectName: sa-tkenTest
 * @author: 小飞
 * @description: TODO
 * @date: 2024/4/16 20:19
 * @version: 1.0
 */
package com.cqie.uaa.exception;

import com.cqie.exception.BaseException;
import com.cqie.result.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
@Slf4j
public class GlobalExceptionHandler {


    /**
     * 全局运行时异常拦截器
     *
     * @param e
     * @return
     */
    @ExceptionHandler(BaseException.class)
    public Result ExceptionHandler(BaseException e) {
        log.info("异常信息为:{}", e.getMessage());
        return Result.error(e.getMessage());
    }

    /**
     * 全局异常拦截器
     *
     * @param e
     * @return
     */
    @ExceptionHandler(Exception.class)
    public Result ExceptionHandler(Exception e) {
        log.info("异常信息为:{}", e.getMessage());
        return Result.error(e.getMessage());
    }
}

